<?php 
    function selectGT($selected = false)
    {
    	$arr = array('Nam','nu');
    	$html = '<select id="gender" name="gender" class="select" title="Select"><option value="">Select</option>';
    	foreach($arr as $values){
    		if($values == $selected  ){
    			$html .= '<option value="'.$values.'" selected="selected">'.ucfirst($values).'</option>';
    		}
    		else{
    			$html .= '<option value="'.$values.'">'.ucfirst($values).'</option>';
    		}
    	}
    	$html .= '</select>';
    	return $html;
    }
     function uploadFile($file,$url,$allowType=array(),$maxSize=1000000){
        $fName=$file['name'];// $_FILES['txtFile']['name']
        $tmpfName=$file['tmp_name'];
        $fSize=$file['size'];
        $ext=getExt($fName);
        if($fSize>$maxSize){
            return 'false';
        }
        if(!in_array($ext,$allowType)){
            return 'false';
        }
        //rename file
        $fName=date('d-m-y-h-i-s').'_'.$fName;
        if(move_uploaded_file($tmpfName, $url.$fName)){
            return $fName;
        }
    }
function phantrang($page, $totalpage, $link, $show)  //$link = '&page=%s'
{
    //show page
if($totalpage == 0)
{
return 'Page 0 of 0';
} else {
    $nav_page = '<div class="navpage"><span class="current">Page '.$page.' of '.$totalpage.': </span>';
    $limit_nav = 3;
    $start = ($page - $limit_nav <= 0) ? 1 : $page - $limit_nav;
    $end = $page + $limit_nav > $totalpage ? $totalpage : $page + $limit_nav;
    if($page + $limit_nav >= $totalpage && $totalpage > $limit_nav * 2){
        $start = $totalpage - $limit_nav * 2;
    }
    if($start != 1){ //show first page
        $nav_page .= '<span class="item"><a href="'.sprintf($link, 1).'"> [1] </a></span>';
    }
    if($start > 2){ //them nut ...
        $nav_page .= '<span class="current">...</span>';
    }
    if($page > 5){ //them nut prev
        $nav_page .= '<span class="item"><a href="'.sprintf($link, $page-5).'">&laquo;</a></span>';
    }
    for($i = $start; $i <= $end; $i++){
        if($page == $i)
            $nav_page .= '<span class="current">'.$i.'</span>';
        else
            $nav_page .= '<span class="item"><a href="'.sprintf($link, $i).'"> ['.$i.'] </a></span>';
    }
    if($page + 3 < $totalpage){ //them nut next
        $nav_page .= '<span class="item"><a href="'.sprintf($link, $page+4).'">&raquo;</a></span>';
    }
    if($end + 1 < $totalpage){ //them nut ...
        $nav_page .= '<span class="current">...</span>';
    }    
    if($end != $totalpage) //show last page
        $nav_page .= '<span class="item"><a href="'.sprintf($link, $totalpage).'"> ['.$totalpage.'] </a></span>';
    $nav_page .= '</div>';
    return $nav_page;
}
}
?>